package cn.bearspark.like.provider.rpc;

import cn.bearspark.like.provider.service.CommentLikeService;
import cn.bearspark.like.provider.service.HappeningLikeService;
import cn.bearspark.like.rpc.LikeRpc;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;

/**
 * @author f
 */
@Component
@DubboService
public class LikeRpcImpl implements LikeRpc {

    private final HappeningLikeService happeningLikeService;
    private final CommentLikeService commentLikeService;

    public LikeRpcImpl(HappeningLikeService happeningLikeService,
                       CommentLikeService commentLikeService) {
        this.happeningLikeService = happeningLikeService;
        this.commentLikeService = commentLikeService;
    }

    @Override
    public int likeHappening(long userId, long happeningId, int liked) {
        return happeningLikeService.likeHappening(userId, happeningId, liked);
    }

    @Override
    public int likeComment(long userId, long commentId, int liked) {
        return commentLikeService.likeComment(userId, commentId, liked);
    }

    @Override
    public List<Long> pageHappeningLikedUserId(int pageNum, int pageSize, long happeningId) {
        return happeningLikeService.pageHappeningLikedUserId(pageNum, pageSize, happeningId);
    }

    @Override
    public Set<Long> getLikedHappeningIdSet(List<Long> happeningIdList, long userId) {
        return happeningLikeService.getLikedHappeningIdSet(happeningIdList, userId);
    }

    @Override
    public boolean isHappeningLiked(long happeningId, long userId) {
        return happeningLikeService.isHappeningLiked(happeningId, userId);
    }

    @Override
    public Set<Long> getLikedCommentIdSet(List<Long> commentIdList, long userId) {
        return commentLikeService.getLikedCommentIdSet(commentIdList, userId);
    }
}
